<style type="text/css">
.labelhide .layui-form-label{display:none;}
.layui-form-label{width:90px;}
.layui-input-block {margin-left:120px;}
form{margin-right:20px;margin-top:10px;}
.layui-form-item{margin-bottom:10px;}
.logic .layui-form-label{padding:9px 3px;width:70px;}
.logic .layui-input-block{margin-left:86px;}
.layui-laydate-header{padding:0px 0px 0px 0px;}
.layui-laydate-list{padding:0px;}
.layui-laydate-content{padding:0px;}
</style>
<form class="layui-form" action="{:url()}" method="post" id="editForm">
<table width="100%" border="0">
    <tr>
        <td colspan="2">
            <table width="100%" border="0">
              <tr>
                <td>{:FormExt::setInputInline(false)}
      {:FormExt::input('标签名称', 'label_name',$labelInfo['label_name'], '单行输入', 'required', 'lay-verify="required"')}</td>
                <td width="230" style="padding-left:15px;padding-bottom:10px;">标签背景色：<span class="label_color"></span>
                <input id="label_color" name="label_color" type="hidden" style="width:110px;height:32px;" /></td>
              </tr>
            </table>
        </td>
    </tr>
    <!--<tr>
        <td colspan="2"><table width="100%" border="0">
              <tr>
                <td>{:FormExt::select('所属菜单', 'storehouse_id', '', $storehouseKV, '', '', 'lay-filter="storehouse-id"')}</td>
                <td>{:FormExt::select('二级菜单', 'menu_id', '', [], '', '')}</td>
              </tr>
            </table>    </td>
    </tr>-->
    <tr>
        <td colspan="2"><div style="color:red;border-top:1px solid #ccc;padding-top:3px;">第二步：配置搜索条件</div></td>
    </tr>
    <tr>
        <td colspan="2">
        	<table width="100%" border="0">
              <tr>
                <td width="120" align="right">*搜索物料状态：</td>
                <td><div id="search_data_status" class="layui-form-item"></div></td>
                <td width="230"><div class="logic">{:FormExt::select('状态关系','m_status_logic',$labelInfo['m_status_logic'], ['or'=>'符合一项即展示', 'and'=>'符合全部才展示'])}</div></td>
              </tr>
            </table>        </td>
    </tr>
    <tr>
        <td colspan="2">
        	<table width="100%" border="0">
              <tr>
                <td width="120" align="right">*搜索工厂：</td>
                <td><div id="factory_ids"></div></td>
                <!--<td width="120"><div style="padding-left:15px;">
                <input name="empty_factory_order" type="checkbox" value="1" {if ($empty_factory_order==1)}checked="checked"{/if} lay-skin="primary" title="包括未分厂" /></div></td>-->
              </tr>
            </table>        </td>
    </tr>
     <tr>
        <td width="120" align="right" valign="middle" >*搜索截至时间：</td>
      <td style="line-height:26px;padding-top:12px;"><input type="text" valign="middle" name="search_end_time" autocomplete="off" id="search_end_time" value="{if (empty($labelInfo['search_end_time']))}18:00:00{/if}{:$labelInfo['search_end_time']}" size="8" style="height:26px;"  lay-verify="required" />
        <input type="radio" name="search_history" value="today" title="只统计当天" {if ($labelInfo['search_history']=='today')}checked=""{/if}>
        <input type="radio" name="search_history" value="yestoday" title="只统计前一天" {if ($labelInfo['search_history']=='yestoday')}checked=""{/if}>
        <input type="radio" name="search_history" value="all" title="统计全部" {if ($labelInfo['search_history']=='all' || empty($labelInfo['search_history']))} checked=""{/if}>
      <div style="color:#999;text-align:right;">备注：该时间为物料进入对应状态的时间节点</div>
      </td>
    </tr>
    <tr>
    	<td colspan="2" style="padding:4px 0px;">
        <table width="100%" border="0">
          <tr>
            <td width="120" align="right">*显示物料类型：</td>
            <td>
            
            {:Form::select('search_materal_type',$search_materal_type, [0 => '全部', 1=>'面料', 2=>'铺料'])}</td>
            <td>
            <div class="layui-inline">
				<label class="layui-form-label" style="width:46px;">单类</label>
				<div class="layui-input-inline">
					{:Form::select('order_type',$labelInfo['order_type'], [''=>'全部','normal'=>'返单','new'=>'首单','emergent'=>'紧急单','my_return_first'=>'初返'], '', '')}
				</div>
			</div>
            </td>
          </tr>
        </table>        </td>
    </tr>


    <tr>
        <td colspan="2">
            <table width="100%" border="0">
                <tr>
                    {:FormExt::select('断码情况:','break_code_status',$labelInfo['break_code_status'], [''=>'全部','1'=>'正常','2'=>'将断码','3'=>'已断码'],'','')}
                </tr>
            </table>  </td>
    </tr>
    <tr>
        <td height="41" colspan="2" style=""><div style="color:red;border-top:1px solid #ccc;padding-top:3px;">第三步：配置可访问帐号</div></td>
    </tr>
    <!--<tr>
        <td colspan="2">
        	<table width="100%" border="0">
              <tr>
                <td width="120" align="right">可访问角色：</td>
                <td><div id="visit_role_ids"></div></td>
              </tr>
            </table>        </td>
    </tr>-->
    <tr>
        <td colspan="2">
        	<table width="100%" border="0">
              <tr>
                <td width="120" align="right">*可访问帐号：</td>
                <td>
                	<table width="100%" border="0" cellspacing="8" >
                      <tr>
                        <!--<td align="left" width="200" class="labelhide">{:Form::select('storehouse_id', '', $role_names, '', '', 'lay-filter="storehouse-id"')}</td>-->
                        <td><div id="visit_admin_ids" style="margin-left:15px;"></div></td>
                      </tr>
                    </table>                </td>
              </tr>
            </table>        </td>
    </tr>
</table>
<div class="pop-bottom-bar">
    	<input type="hidden" class="field-id" name="id" value="{:$labelInfo['id']}">
        <!--<button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit">提交保存</button>-->
        <button type="submit" id="btnrejects" class="layui-btn mimo-tab layui-btn-normal" lay-submit="" tabindex="101" lay-filter="rejects">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

{include file="system@block/layui" /}
<script src="__PUBLIC_JS__/xm-select/dist/xm-select.js"></script>
<script>
    var formData = {:json_encode($formData)};
	var storeshelfMap = {:json_encode($storeshelfMap)};
    layui.use(['form', 'func','laydate','colorpicker'], function() {
        var $ = layui.jquery, form = layui.form,laydate=layui.laydate,colorpicker = layui.colorpicker;
        layui.func.assign(formData);
		
		laydate.render({ 
		  elem: '#search_end_time'
		  ,type: 'time'
		});
		colorpicker.render({
			elem: '.label_color'
			,color:'{:$bgcolor}'
			,predefine: true
			,colors: ['#c2c2c2','#FF5722','#009688','#5FB878','#393D49','#1E9FFF','#FFB800','#01AAED','#2F4056']
			,done: function(color){
				$("#label_color").val(color);
			}
		});
		// 货仓下拉切换
    	form.on('select(storehouse-id)', function(data){
    		var optionArr = storeshelfMap[data.value];
    		var option = '';
    		for(var i in optionArr) {
    			option += '<option value="'+i+'">'+optionArr[i]+'</option>';
    		}
    		$("select[name=menu_id] option").remove();
    		$('select[name=menu_id]').append(option);
    		form.render();
    	});
		//监听提交
		form.on('submit(rejects)', function(data){
			var datalist = data.field;
			console.log(datalist);
			
			if(datalist.search_data_status==''){
				layer.msg('搜索物料状态必填', {icon: 2,anim: 6});
				return false;
			}
			if(datalist.factory_ids==''){
				layer.msg('搜索工厂必填', {icon: 2,anim: 6});
				return false;
			}
			if(datalist.visit_admin_ids==''){
				layer.msg('可访问帐号必填', {icon: 2,anim: 6});
				return false;
			}
			$.ajax({
			   type: "POST",
			   url: "{:url('searchLabelList')}?use_action=edit_search_label",
			   data: data.field,
			   dataType:"json",
			   success: function(res){
				  if (res.code == 1) {
					 layer.msg(res.msg, {icon: 1,time:600,end:function(){
						parent.layui.layer.closeAll();
						parent.location.reload();
					 }});
				  } else {
					 layer.msg(res.msg, {icon: 2,anim: 6,time:4000});
				  }
			   }
			});
			return false;
		});
		
		var demo1 = xmSelect.render({
			el: '#search_data_status', 
			name:'search_data_status',
			autoRow: true,
			filterable: true,
			data: {:json_encode($materialStatus)}
		})
		var demo1 = xmSelect.render({
			el: '#factory_ids', 
			name:'factory_ids',
			autoRow: true,
			filterable: true,
			toolbar: {
				show: true,
				list: ['ALL', 'CLEAR']
			},
			data: {:json_encode($factorylist)}
		})
		var demo4 = xmSelect.render({
			el: '#visit_role_ids', 
			name:'visit_role_ids',
			autoRow: true,
			filterable: true,
			data: {:json_encode($visit_role_ids)}
		})
		var demo3 = xmSelect.render({
			el: '#visit_admin_ids', 
			name:'visit_admin_ids',
			autoRow: true,
			filterable: true,
			data: {:json_encode($visit_admin_ids)}
		});
    });
</script>